﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="FillShopInfo_New.ascx.cs"
    Inherits="UserControls_FillShopInfo_New" %>
<%@ Register Assembly="Shove.Web.UI.4 For.NET 2.0" Namespace="Shove.Web.UI" TagPrefix="ShoveWebUI" %>
<link href="Style/common.css" rel="stylesheet" type="text/css" />
<link href="Style/orderInfo.css" rel="stylesheet" type="text/css" />
<link href="Style/shoppingcart.css" rel="stylesheet" type="text/css" />
<style>
    .formtips
    {
        width: 200px;
        margin: 2px;
        padding: 2px;
    }
    .onError
    {
        background: #FFE0E9 url(images/UserControls/reg3.gif) no-repeat 0 center;
        padding-left: 25px;
    }
</style>

<script src="Components/JQuery/JavaScript/jquery.js" type="text/javascript"></script>

<script type="text/javascript">   
	$(function(){
		//收货人姓名失去焦点事件
		$("#ShoveWebPart3_ctl00_tbName").blur(function(){			
			if(this.value != ""){
				$("#spanName").text("");
			}		
		})
	
		//收货地址失去焦点事件
		$("#ShoveWebPart3_ctl00_tbAddress").blur(function(){			
			if(this.value != ""){
				$("#spanAddress").text("");
			}		
		})
				
	})
	
	//修改收货人信息
    function showForm_consignee(obj){
		if($("div.middle:first").is(":visible")){
			$('div.o_show h1 a:first').text("[关闭]");
			$("#div_consignee:first").show();
            $("div.middle:first").hide();
			
            //加载数据
            var name = $("#ShoveWebPart3_ctl00_lbName").text();            				
			var province = $("#ShoveWebPart3_ctl00_lbProvince").text();
			var city = $("#ShoveWebPart3_ctl00_lbCity").text(); 	
			var address = $("#ShoveWebPart3_ctl00_lbAddress").text();					
			var postcode = $("#ShoveWebPart3_ctl00_lbPostCode").text(); 
			var tel = $("#ShoveWebPart3_ctl00_lbTel").text(); 
			var mobile = $("#ShoveWebPart3_ctl00_lbMobile").text(); 
			var email = $("#ShoveWebPart3_ctl00_lbEmail").text(); 
						
			$("#ShoveWebPart3_ctl00_tbName")[0].value = name;	
			$("#ShoveWebPart3_ctl00_tbProvince").text(province);
			$("#ShoveWebPart3_ctl00_tbCity").text(city);
			$("#ShoveWebPart3_ctl00_tbAddress")[0].value = address;	
			$("#ShoveWebPart3_ctl00_tbPostCode")[0].value = postcode;	
			$("#ShoveWebPart3_ctl00_tbTel")[0].value = tel;	
			$("#ShoveWebPart3_ctl00_tbMobile")[0].value = mobile;	
			$("#ShoveWebPart3_ctl00_tbEmail")[0].value = email;																					
					
		}else{
			$('div.o_show h1 a:first').text("[修改]");			
			$("#div_consignee:first").hide();
            $("div.middle:first").show();            
		}
    }

    //保存收货人信息
	function editForm_consignee(obj){
		var name = $("#ShoveWebPart3_ctl00_tbName").val();
		var address = $("#ShoveWebPart3_ctl00_tbAddress").val();
		var province = $("#ShoveWebPart3_ctl00_tbProvince").text();
		var city = $("#ShoveWebPart3_ctl00_tbCity").text();
		
		if(name == ""){
			$("#spanName").addClass("formtips onError").text("收货人姓名不能为空!");					
			return false;
		}
		if(address == ""){
			$("#spanAddress").addClass("formtips onError").text("收货地址不能为空!");
			return false;
		}	
				
		var postcode = $("#ShoveWebPart3_ctl00_tbPostCode").val();
		var tel = $("#ShoveWebPart3_ctl00_tbTel").val();
		var mobile = $("#ShoveWebPart3_ctl00_tbMobile").val();	
		var email = $("#ShoveWebPart3_ctl00_tbEmail").val();				
				
		$("#ShoveWebPart3_ctl00_lbName").text(name);		
		$("#ShoveWebPart3_ctl00_lbProvince").text(province);
		$("#ShoveWebPart3_ctl00_lbCity").text(city);
		$("#ShoveWebPart3_ctl00_lbAddress").text(address);
		$("#ShoveWebPart3_ctl00_lbPostCode").text(postcode);
		$("#ShoveWebPart3_ctl00_lbTel").text(tel);
		$("#ShoveWebPart3_ctl00_lbMobile").text(mobile);
		$("#ShoveWebPart3_ctl00_lbEmail").text(email);		
		
		$('div.o_show h1 a:first').text("[修改]");			
		$("#div_consignee:first").hide();
        $("div.middle:first").show();   
	}
	
	// 选择支付方式	
    function selectPayType()
    {                
        if(document.getElementById("ShoveWebPart3_ctl00_rblPayType_0").checked) //支付宝支付 
        {
            document.getElementById("div1").style.display = "block";
            document.getElementById("div2").style.display = "none";
            document.getElementById("div3").style.display = "none";
            document.getElementById("div4").style.display = "none";   
        } 
        else if(document.getElementById("ShoveWebPart3_ctl00_rblPayType_1").checked)  //网银支付
        {
            document.getElementById("div1").style.display = "none";
            document.getElementById("div2").style.display = "block";
            document.getElementById("div3").style.display = "none";
            document.getElementById("div4").style.display = "none";
        }   
        else if(document.getElementById("ShoveWebPart3_ctl00_rblPayType_2").checked)  //银行转帐
        {
            document.getElementById("div1").style.display = "none";
            document.getElementById("div2").style.display = "none";
            document.getElementById("div3").style.display = "block";
            document.getElementById("div4").style.display = "none";
        }   
        else if(document.getElementById("ShoveWebPart3_ctl00_rblPayType_3").checked)  //公司转帐
        {
            document.getElementById("div1").style.display = "none";
            document.getElementById("div2").style.display = "none";
            document.getElementById("div3").style.display = "none";
            document.getElementById("div4").style.display = "block";
        } 
    }
    
    // 选择配送方式	
    function selectCarriageType()
    {                 
        var len = document.getElementById("ShoveWebPart3_ctl00_rblCarriageType").cells.length;

        for(var i=0; i< len; i++)
        {
            var radio = "ShoveWebPart3_ctl00_rblCarriageType_" + i;
            var radiovalue = document.getElementById(radio).value;                   
            
            if(document.getElementById(radio).checked)
            {                      
                Ajax.Control.GetCarriageTypeMoneyByID(radiovalue, CarriageType_CallBack);
                break;
            }      
        }               
    }
    
    function CarriageType_CallBack(response)
    {
        var value = response.value;
        
        if(value != "")
        {        
            document.getElementById("ShoveWebPart3_ctl00_lbCarriageMoney").innerText = response.value;
            document.getElementById("ShoveWebPart3_ctl00_lbCarriageMoney2").innerText = response.value;
            
            var GoodMoney = parseFloat(document.getElementById("ShoveWebPart3_ctl00_lbGoodMoney").innerText);            
            document.getElementById("ShoveWebPart3_ctl00_lbSumMoney").innerText = GoodMoney + parseFloat(response.value);
        }
    }
    
	//修改订单备注
	function showForm_remark(obj){
		if($("#middleDiv").is(":visible")){
			$('#showDiv h1 a:first').text("[关闭]");
			$("#div_remark").show();
            $("#middleDiv").hide();
			
			 //加载数据
            var remark = $("#ShoveWebPart3_ctl00_lbRemark").text();            				
			if(remark == '暂无备注'){
				remark = '';
			}
							
			$("#ShoveWebPart3_ctl00_tbRemark")[0].value = remark;																											
		}else{					
			$('#showDiv h1 a:first').text("[修改]");			
			$("#div_remark").hide();
            $("#middleDiv").show();            
		}
	}
	
	//保存订单备注
	function editForm_remark(obj){
		var remark = $("#ShoveWebPart3_ctl00_tbRemark").val();
		
		if(remark == ""){
			remark = '暂无备注';
		}	
				
		$("#ShoveWebPart3_ctl00_lbRemark").text(remark);
		
		$('#showDiv h1 a:first').text("[修改]");			
		$("#div_remark").hide();
        $("#middleDiv").show();    
	}
	
    //校验信息
    function Check()
    {         
        if($("#div_consignee").is(":visible")){
			alert('请保存收货人信息');
			return false;
		}
		
		if($("#div_remark").is(":visible")){
			alert('请保存订单备注信息');
			return false;
		}
		
		var GoodMoney = document.getElementById("<%=this.lbGoodMoney.ClientID %>").innerText;

		if(GoodMoney == ""){
		    GoodMoney = 0;
		}else{		
		    GoodMoney = parseFloat(GoodMoney);
		}
		
		if(GoodMoney <= 0){
		    alert("购物车内无任何商品，订单不能提交！");
		    return false;
		}		
		
        return confirm("确认保存该订单!");    
    }
    
    //选择省份
    function ddlProvinceChange(e)
    {
        var value = e.value;
        document.getElementById('<%=this.tbProvince.ClientID%>').innerText = e.options[e.selectedIndex].text;
        
        Ajax.ShopCustomer.GetCity(value,ddlProvinceChange_callback);
    }
    
    function ddlProvinceChange_callback(res)
    {
        var dt = res.value;  
        document.getElementById('<%=this.ddlCity.ClientID%>').length=0;
        
        document.getElementById('<%=this.tbCity.ClientID%>').innerText = dt.Rows[0]["Name"];
        
        for(var i=0; i<dt.Rows.length; i++)
        {
            var name=dt.Rows[i]["Name"];             
            var id=dt.Rows[i]["ID"];
            if(i==0)
            {
                document.getElementById('<%=this.hOneCity.ClientID%>').value=name;
                document.getElementById('<%=this.hCity.ClientID%>').value = id;    //保存CityID
            }
           document.getElementById('<%=this.ddlCity.ClientID%>').options.add(new Option(name,id));                                            
        }                
    }
    
    function ddlCityChange(e)
    {
        document.getElementById('<%=this.hCity.ClientID%>').value = e.options[e.selectedIndex].text;        
        document.getElementById('<%=this.hCity.ClientID%>').value = e.options[e.selectedIndex].value;   //保存CityID
        
        document.getElementById('<%=this.tbCity.ClientID%>').innerText = e.options[e.selectedIndex].text; 
    }
    
</script>

<div class="Wrap_cart">
    <div id="Top1_order_step2" class="Header_cart">
        <ul class="Order_cart" id="Order_cart_S2">
            <li class="step1 s1complete"><a href="Default.aspx?PN=cart" style="color: #000">1.我的购物车</a></li>
            <li class="step2">2.填写核对订单信息</li>
            <li class="step3">3.成功提交订单</li>
        </ul>
    </div>
    <%--<div id='stockErrorPanel' style="text-align: left;">
        <img alt="" src="images/UserControls/cart_001.jpg" />
    </div>--%>
    <!--mycart_tip end -->
    <div id='Promo_panel'>
    </div>
    <div class="List_cart marginb10">
        <h2>
            <strong>填写核对订单信息</strong></h2>
        <div class="cart_table">
            <!--收货人地址开始-->
            <div id="part_consignee">
                <div class='o_show'>
                    <h1>
                        收货人信息&nbsp;<a id='lbtnConsigneeWrite' href='javascript:void(0)' onclick='showForm_consignee(this)'>[修改]</a>
                    </h1>
                    <div class='middle'>
                        <table>
                            <tr>
                                <td style='width: 80px;' align='right'>
                                    收货人姓名：
                                </td>
                                <td>
                                    <asp:Label ID="lbName" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>                                                                                                                                         
                            <tr>
                                <td align='right'>
                                    详细地址：
                                </td>
                                <td>
                                    <asp:Label ID="lbProvince" runat="server" Text=""></asp:Label>&nbsp;
                                    <asp:Label ID="lbCity" runat="server" Text=""></asp:Label>&nbsp;
                                    <asp:Label ID="lbAddress" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align='right'>
                                    邮 编：
                                </td>
                                <td>
                                    <asp:Label ID="lbPostCode" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align='right'>
                                    固定电话：
                                </td>
                                <td>
                                    <asp:Label ID="lbTel" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align='right'>
                                    手机号码：
                                </td>
                                <td>
                                    <asp:Label ID="lbMobile" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align='right'>
                                    电子邮件：
                                </td>
                                <td>
                                    <asp:Label ID="lbEmail" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div id="div_consignee" style="display: none;">
                        <table style="background-color: #AACDED">
                            <tr>
                                <td style='width: 80px;' align='right'>
                                    <font color="red">*</font>收货人姓名：
                                </td>
                                <td>
                                    <asp:TextBox ID="tbName" runat="server"></asp:TextBox>
                                    &nbsp;<span id="spanName"></span>
                                </td>
                            </tr>
                            <tr>
                                <td align='right'>
                                    国 家：
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddlProvince" runat="server" Width="99px">
                                    </asp:DropDownList>
                                    <asp:DropDownList ID="ddlCity" runat="server" Width="97px">
                                    </asp:DropDownList>
                                </td>
                            </tr>   
                            <tr>
                                <td align='right'>
                                    <font color="red">*</font>详细地址：
                                </td>
                                <td>
                                    <asp:Label ID="tbProvince" runat="server" Text=""></asp:Label>&nbsp;
                                    <asp:Label ID="tbCity" runat="server" Text=""></asp:Label>&nbsp;
                                    <asp:TextBox ID="tbAddress" runat="server" Width="250px"></asp:TextBox>&nbsp;<span
                                        id="spanAddress"></span>
                                </td>
                            </tr>
                            <tr>
                                <td align='right'>
                                    邮 编：
                                </td>
                                <td>
                                    <asp:TextBox ID="tbPostCode" runat="server" Width="100px"></asp:TextBox>
                                    &nbsp;有助于快速确定送货地址
                                </td>
                            </tr>
                            <tr>
                                <td align='right'>
                                    固定电话：
                                </td>
                                <td>
                                    <asp:TextBox ID="tbTel" runat="server"></asp:TextBox>&nbsp;如：010-12345678，固话与手机至少填写一项
                                </td>
                            </tr>
                            <tr>
                                <td align='right'>
                                    手机号码：
                                </td>
                                <td>
                                    <asp:TextBox ID="tbMobile" runat="server"></asp:TextBox>&nbsp;填写手机号便于接收发货通知短信及送货前确认
                                </td>
                            </tr>
                            <tr>
                                <td align='right'>
                                    电子邮件：
                                </td>
                                <td>
                                    <asp:TextBox ID="tbEmail" runat="server"></asp:TextBox>&nbsp;用来接收订单提醒邮件，便于您及时了解订单状态
                                </td>
                            </tr>
                            <tr>
                                <td align="left" colspan="2">
                                    &nbsp;&nbsp;<input id="btnConsignee" type="button" value="保存收货人信息" onclick="editForm_consignee(this)"
                                        style="background-color: #FFE658" />
                                </td>
                            </tr>
                        </table>
                    </div>
                    <br />
                </div>
            </div>
            <!--收货人地址结束-->
            <!--支付方式及配送方式开始-->
            <div id="part_payTypeAndShipType">
                <div class='o_show'>
                    <h1>
                        支付及配送方式&nbsp;<a id='linkPayTypeShipType' href='javascript:void(0)' onclick='showForm_payTypeAndShipType(this);'
                            style='display: '></a></h1>
                    <div id='updateInfo_payType'>
                    </div>
                    <div class='middle'>
                        <table>
                            <tr>
                                <td style='width: 80px;' align='right'>
                                    支付方式：
                                </td>
                                <td>
                                    <asp:RadioButtonList ID="rblPayType" runat="server" RepeatDirection="Horizontal">
                                    </asp:RadioButtonList>
                                </td>
                            </tr>
                            <tr>
                                <td align="left" colspan="2">
                                    <div id="div1" style="display: block;">
                                        <table style="background-color: #AACDED">
                                            <tr>
                                                <td style='width: 80px;' align='right'>
                                                    支付宝：
                                                </td>
                                                <td>
                                                    http://www.alipay.com
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                    <div id="div2" style="display: none;">
                                        <table style="background-color: #AACDED">
                                            <tr>
                                                <td style='width: 80px;' align='right'>
                                                    建设银行：
                                                </td>
                                                <td>
                                                    6227 0016 3120 0204 703
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style='width: 80px;' align='right'>
                                                    工商银行：
                                                </td>
                                                <td>
                                                    6222 0213 0200 4544 564
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style='width: 80px;' align='right'>
                                                    中国银行：
                                                </td>
                                                <td>
                                                    6013 8215 0000 1547 127
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style='width: 80px;' align='right'>
                                                    邮储银行：
                                                </td>
                                                <td>
                                                    6221 8837 2200 5282 139
                                                </td>
                                            </tr>                                         
                                        </table>
                                    </div>
                                    <div id="div3" style="display: none; background-color: #AACDED;">
                                        <table style="background-color: #AACDED">
                                            <tr>                                            
                                                <td style='width: 250px;' align='right' colspan="2">                                                                                                
                                                    户  名	合肥市百齐网络科技有限公司<br />
                                                    开户行	工商银行合肥市三牌楼分理处<br />
                                                    账  号	1302—0141—0920—0044—969
                                                </td>
                                            </tr>                                            
                                        </table>
                                    </div>
                                    <div id="div4" style="display: none; background-color: #AACDED;">
                                        <table style="background-color: #AACDED">
                                            <tr>
                                                <td style='width: 80px;' align='right'>
                                                    邮政储蓄：
                                                </td>
                                                <td>
                                                    6221 8837 2200 5282 139 慕孟振
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td style='width: 80px;' align='right'>
                                    配送方式：
                                </td>
                                <td>
                                    <asp:RadioButtonList ID="rblCarriageType" runat="server" RepeatDirection="Horizontal">
                                    </asp:RadioButtonList>
                                </td>
                            </tr>
                            <tr>
                                <td style='width: 80px;' align='right'>
                                    邮 费：
                                </td>
                                <td>
                                    &nbsp;<asp:Label ID="lbCarriageMoney" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <br />
                </div>
            </div>
            <!--支付方式及配送方式结束-->
            <!--发票信息开始-->
            <div id="part_invoice">
                <div class='o_show'>
                    <h1>
                        发票信息&nbsp;<a href='javascript:void(0)' onclick='showForm_invoice(this)'></a></h1>
                    <div class='middle'>
                        <table style='width: 100%; display: '>
                            <tr>
                                <td style='width: 80px;' align='right'>
                                    <font color="red">*</font>索要发票：
                                </td>
                                <td>
                                    <asp:RadioButtonList ID="rblTicket" runat="server" RepeatDirection="Horizontal">
                                        <asp:ListItem Value="0" Selected="True">不需要</asp:ListItem>
                                        <asp:ListItem Value="1">需 要</asp:ListItem>
                                    </asp:RadioButtonList>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <br />
                </div>
            </div>
            <!--发票信息结束-->
            <!--订单备注开始-->
            <div id="part_remark">
                <div class='o_show' id="showDiv">
                    <h1>
                        订单备注&nbsp;<a href='javascript:void(0)' onclick='showForm_remark(this)'>[修改]</a></h1>
                    <div id="middleDiv" style="text-align: left;">
                        <table style='width: 800px'>
                            <tr>
                                <td style='text-align: left; padding-left: 20px;'>
                                    <asp:Label ID="lbRemark" runat="server" Text="暂无备注"></asp:Label>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div id="div_remark" style="display: none;">
                        <table id="tableRemark" style="background-color: #AACDED">
                            <tr>
                                <td style='width: 80px;' align='right'>
                                    订单备注：
                                </td>
                                <td>
                                    <asp:TextBox ID="tbRemark" runat="server" Width="250px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td align="left" colspan="2">
                                    &nbsp;&nbsp;<input id="btnConsignee" type="button" value="保存订单备注" onclick="editForm_remark(this)"
                                        style="background-color: #FFE658" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
             </div>
                <!--订单备注结束-->
                <!--Cart信息开始-->
                <div id="part_cart">
                    <div class='o_show'>
                        <h1>
                            <span style='margin-right: 700px;'>商品清单</span><a href='Default.aspx?PN=cart' style='color: #0070D7'>返回修改购物车</a></h1>
                        <div class='middle'>
                            <asp:GridView ID="gvGood" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
                                Style="text-align: center" Width="100%" OnRowDataBound="gvGood_RowDataBound">
                                <Columns>
                                    <asp:BoundField DataField="GoodNo" HeaderText="商品编号" />
                                    <asp:BoundField DataField="GoodName_CN" HeaderText="商品名称" />
                                    <asp:BoundField DataField="Price_Orig" HeaderText="普通价格" />
                                    <asp:BoundField DataField="Price_Vip" HeaderText="会员价" />
                                    <asp:TemplateField HeaderText="数量">
                                        <ItemTemplate>
                                            &nbsp;<asp:TextBox ID="txtNum" runat="server" onkeyup="value=value.replace(/[^\d]/g,'');updateQuantity(this.value)"
                                                Text='<%# Eval("Amount") %>' Width="39px"></asp:TextBox>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="SumMoney" HeaderText="金额" />
                                </Columns>
                                <HeaderStyle BackColor="Silver" BorderStyle="Double" />
                            </asp:GridView>
                        </div>
                        <div class='footer'>
                        </div>
                    </div>
                </div>
                <!--Cart信息开始-->
                <div id="ware_info">
                    <div style="background: #fff; font-size: 14px; font-weight: bold; padding-left: 2px;">
                        结算信息</div>
                    <h1>
                    </h1>
                    <div class="middle">
                        <!--订单信息-->
                        <ul id='part_info'>
                            <li class='info1' style='padding-bottom: 5px'>商品金额：<asp:Label ID="lbGoodMoney" runat="server"
                                Text=""></asp:Label>
                                元 + 运费：<asp:Label ID="lbCarriageMoney2" runat="server" Text=""></asp:Label>元
                            </li>
                            <li class='info2' style='width: 100%; overflow: hidden;'>
                                <table style='width: 100%' cellpadding='0' cellspacing='0'>
                                    <tr>
                                        <td>
                                        </td>
                                        <td style='text-align: right; font-size: 15px;'>
                                            <b>应付总额：<font color='red'><asp:Label ID="lbSumMoney" runat="server" Text=""></asp:Label></font>
                                                元</b>
                                            <ShoveWebUI:ShoveConfirmButton ID="ibNext" BackgroupImage="images/UserControls/submit.jpg"
                                                Text="" runat="server" Width="160px" Height="53px" OnClick="ibNext_Click" OnClientClick="if (!Check()) return false; this.disabled=true;" />
                                        </td>
                                    </tr>
                                </table>
                            </li>
                        </ul>
                        <!--订单信息结束-->
                    </div>
                </div>
            </div>
            <div class="round">
                <div class="lround">
                </div>
                <div class="rround">
                </div>
            </div>
        </div>
    </div>
    <asp:HiddenField ID="hCartType" runat="server" />
    <!-- 哪个购物车 -->
    <asp:HiddenField ID="hCity" runat="server" />
    <asp:HiddenField ID="hOneCity" runat="server" />
